package com.itheima.congfig;

import com.itheima.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web环境下的核心配置类（...消息转换器，释放静态资源....配置拦截器）
 */
@Configuration //表示类是一个配置类
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    LoginInterceptor loginInterceptor;

    //添加，配置拦截器
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) //添加一个拦截器
                .addPathPatterns("/**") //拦截器拦截的路径
                .excludePathPatterns("/login"); //拦截器不拦截哪些路径
    }
}
